package com.example.jobdemo.job;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class JobDemo01 {


    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("JobDemo01")
    public void demoJobHandler() throws Exception {
        System.out.printf("JobDemo01开始！");

        System.out.println(XxlJobHelper.getJobParam());

        XxlJobHelper.log("JobDemo01: XXL-JOB, Hello World.");
        for (int i = 0; i < 5; i++) {
            XxlJobHelper.log("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
        // default success
        System.out.printf("JobDemo01结束！");
    }
}
